package com.unity3d.sqliteapp8;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class DBOpenHelper extends SQLiteOpenHelper {
    //构造方法
    public DBOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    //创建数据库的表
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        //建表
        sqLiteDatabase.execSQL("create table user(" +
                "id integer " +
                "primary key autoincrement,username " +
                "varchar(20),password varchar(20)," +
                "age integer)");
    }

    //更新数据库的表
    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
